package com.qf.file.config;

import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;

import javax.servlet.MultipartConfigElement;

/**
 * @author 汤奇
 * @version V1.0
 * @Project BookPro
 * @Package com.qf.file.config
 * @Description: 配置上传文件的大小
 * @Date 2022/8/5 21:28
 */
@Configuration
public class MultipartConfig {
    @Bean
    public MultipartConfigElement multipartConfigElement(){
        MultipartConfigFactory factory = new MultipartConfigFactory();
        //限制大小为200m
        DataSize dataSize = DataSize.ofMegabytes(200);
        factory.setMaxFileSize(dataSize);
        factory.setMaxRequestSize(dataSize);
        return factory.createMultipartConfig();
    }
}
